﻿namespace WP7Contrib.Services.BingMaps.Model
{
    using Common;

    public abstract class Result : BaseModel
    {
        private string authenticationResultCode;
        private string copyright;
        private string errorDetails;
        private string statusCode;
        private string statusDescription;
        private string traceId;

        protected Result()
        {
        }

        public string AuthenticationResultCode
        {
            get
            {
                return this.authenticationResultCode;
            }
            set
            {
                this.SetPropertyAndNotify(ref this.authenticationResultCode, value, () => AuthenticationResultCode);
            }
        }

        public string Copyright
        {
            get
            {
                return this.copyright;
            }
            set
            {
                this.SetPropertyAndNotify(ref this.copyright, value, () => Copyright);
            }
        }

        public string ErrorDetails
        {
            get
            {
                return this.errorDetails;
            }
            set
            {
                this.SetPropertyAndNotify(ref this.errorDetails, value, () => ErrorDetails);
            }
        }

        public string StatusCode
        {
            get
            {
                return this.statusCode;
            }
            set
            {
                this.SetPropertyAndNotify(ref this.statusCode, value, () => StatusCode);
            }
        }

        public string StatusDescription
        {
            get
            {
                return this.statusDescription;
            }
            set
            {
                this.SetPropertyAndNotify(ref this.statusDescription, value, () => StatusDescription);
            }
        }

        public string TraceId
        {
            get
            {
                return this.traceId;
            }
            set
            {
                this.SetPropertyAndNotify(ref this.traceId, value, () => TraceId);
            }
        }

        public bool HasSucceeded
        {
            get { return this.StatusCode == "200"; }
        }

        public bool HasError
        {
            get { return !this.HasSucceeded; }
        }

        protected void CloneBaseResult<T>(T instance) where T : Result
        {
            this.AuthenticationResultCode = instance.AuthenticationResultCode;
            this.Copyright = instance.Copyright;
            this.ErrorDetails = instance.ErrorDetails;
            this.StatusCode = instance.StatusCode;
            this.StatusDescription = instance.StatusDescription;
            this.TraceId = instance.TraceId;
        }
    }
}

